package com.tedu.pj.goods.dao;

import com.tedu.pj.goods.pojo.Goods;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/9/29
 */
@Repository
public class GoodsDaoImpl implements GoodsDao {

    @Autowired
    SqlSessionFactory sqlSessionFactory;

    @Override
    public List<Goods> findGoods() {
        //1、获取sqlsession对象
        //2、基于sqlsession实现商品查询
        //3、翻译资源
        //4、返回结果

        SqlSession sqlSession = sqlSessionFactory.openSession();
        String statement = "com.tedu.pj.goods.dao.GoodsDao.findGoods";
        List<Goods> Goods = sqlSession.selectList(statement);
        sqlSession.close();
        return Goods;
    }


}
